package com.mdframe.ai.agent.tools;

import cn.hutool.core.util.StrUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.function.Function;

/**
 * @date 2024/10/17
 */
//@Component
public class GetTableSchemaFunction  implements Function<GetTableSchemaFunction.Request, GetTableSchemaFunction.Response> {
    
    
    @Override
    public Response apply(Request request) {
        if (StrUtil.isNotBlank(request.tableName())) {
            Map<String,String> schemaMap = new MySQLSchemaService().getTableSchema(request.tableName());
            return new Response("columns:" + schemaMap.toString());
        }
        return new Response("请告诉我要查询的表名");
    }
    
    public record Request(String tableName) {
    
    }
    
    public record Response(String description) {
    }
}
